Xbasic

TOKEN_SEARCH_REPLACE Function

Syntax

New_Expn as C = TOKEN_SEARCH_REPLACE(C Expression,C SearchToken1,C ReplaceToken1[...,C SearchTokenN,C ReplaceTokenN])

Arguments

New_Expn

The translated expression.

Expression

The starting expression that contains zero or more instances of the various search arguments.

SearchToken1...SearchTokenN

SearchN The character strings that you are searching for.

ReplaceToken1...ReplaceTokenN

ReplaceN The replacement character strings, paired with the search strings.

Description

Search and replace tokens in an expression, useful for replacing fieldnames and subexpressions.

Discussion

The TOKEN_SEARCH_REPLACE() function replaces multiple search strings with multiple replace strings.

Example

? token_search_replace("if(sf1>sf2, rs1=rs2+1, rs2=rs1-1)", "sf1", "a", "sf2", "b", "rs1", "c", "rs2", "d")
= "if(a>b,c=d+1,d=c-1)"

See Also